<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>斐波那契数列</title>
	</head>
	<body>
		
		<script>
			//获取n
			let n = prompt('请输入要获取斐波那契数列的第几项？',1);
			
			let pre = 1, prePre = 1;
			
			for (let i = 1; i <= n; i++) {
				if(i==1 || i==2){
					console.log(1);
				}else{
					let cur = pre + prePre;//定义一个变量存储当前数
					console.log(cur);
					prePre = pre //让上一个数变成上上一个数
					pre = cur //让当前数变成上一个数
				}
					
			}	
			
			
		</script>
	</body>
</html>